#!/bin/bash

export LC_ALL=C

export BASE_DATA_PATH=/home/mixagol/data/
export BASE_DATE=20120802
export CUR_DIR=${BASE_DATA_PATH}/7_aux/gene_ontology/${BASE_DATE}

mkdir -p ${CUR_DIR}/raw

wget 'http://www.geneontology.org/ontology/go.obo' -O "${CUR_DIR}/raw/go.obo"
pv "${CUR_DIR}/raw/go.obo" | 7_aux/gene_ontology/parse_obo.py | sed 's/^GO://g' > "${CUR_DIR}/go_names.txt"


wget 'ftp://ftp.geneontology.org/pub/go/gene-associations/gene_association.goa_uniprot.gz' -O '${CUR_DIR}/raw/gene_association.goa_uniprot.gz'
pv "${CUR_DIR}/raw/gene_association.goa_uniprot.gz" | zcat \
    | grep '^UniProtKB' \
    | cut -f2,5,9 \
    | sed 's/\tGO:/\t/g' \
    | 7_aux/gene_ontology/create_uniprot2go.py \
    > "${CUR_DIR}/uniprot2go.txt"

